import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';

class MineListCell extends StatelessWidget {
  final VoidCallback? onPressed;
  final Widget? icon;
  final String title;
  final String? trailing;
  final Widget? trailingWidget;

  const MineListCell(
      {Key? key,
      this.onPressed,
      this.icon,
      required this.title,
      this.trailing,
      this.trailingWidget})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onPressed,
      child: Container(
        child: Column(
          children: <Widget>[
            Container(
              padding: EdgeInsets.only(
                left: icon == null ? 0 : 20,
                right: 20,
                top: 12,
                bottom: 12,
              ),
              child: Row(
                children: <Widget>[
                  icon ?? Container(),
                  icon == null ? Container() : SizedBox(width: 14),
                  Text(title, style: TextStyle(fontSize: 16)),
                  Expanded(child: Container()),
                  TextUtil.isEmpty(trailing)
                      ? trailingWidget == null
                          ? Container()
                          : Row(
                              children: [
                                trailingWidget!,
                                SizedBox(
                                  width: 10,
                                ),
                              ],
                            )
                      : Row(
                          children: [
                            Text(
                              trailing!,
                              style: TextStyle(
                                  fontSize: 14, color: Colors.black38),
                            ),
                            SizedBox(
                              width: 10,
                            ),
                          ],
                        ),
                  Icon(
                    Icons.keyboard_arrow_right_outlined,
                    color: Colors.black38,
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
